package com.taotao.search.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
/**
 * 全局异常处理器
 * @author Administrator
 *
 */
public class GloblExceptionResovler implements HandlerExceptionResolver{

	private static Logger logger=Logger.getLogger(GloblExceptionResovler.class);
	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception e) {
		// 先写日志
		logger.error("运行时异常",e);
		//发短信 邮件 第三方运营商的插件
		//捕获异常 跳转到友好的界面
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("error/exception");
		modelAndView.addObject("message", "您的网络异常 ,喊皮皮涛过来重试");
		return modelAndView;
	}

}
